import 'package:flutter/material.dart';

class LayoutDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          ConstrainedBox(
            constraints: BoxConstraints(
              minHeight: 200.0,
            ),
            child: Container(
              color: Colors.red,
            ),
          )
        ],
      ),
    );
  }
}


//设置宽高比 布局
class AspectRatioDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AspectRatio(   //AspectRatio :宽高比
      aspectRatio: 3.0/2.0,
      child: Container(
        color: Color.fromRGBO(3, 54, 255, 1.0),
      ),
    );
  }
}



// Stack 布局
class StackDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child:Stack( //Stack 使部件叠加
        alignment: Alignment.topRight,
        children: <Widget>[
          SizedBox(
            width: 200.0,
            height: 300.0,
            child: Container(
              alignment: Alignment(0.0, -0.9),
              decoration: BoxDecoration(
                  color: Color.fromRGBO(3, 54, 255, 1.0),
                  borderRadius: BorderRadius.circular(8.0)
              ),
//                  child: Icon(Icons.ac_unit,color: Colors.white,size: 32,),
            ),
          ),
          SizedBox(
            height: 32.0,
          ),
          SizedBox(
            width: 50.0,
            height: 50.0,
            child: Container(
              decoration: BoxDecoration(
                  color: Color.fromRGBO(3, 54, 255, 1.0),
                  borderRadius: BorderRadius.circular(8.0)
              ),
              child: Icon(Icons.message,color: Colors.white,size: 32,),
            ),
          ),
          Positioned(child: Icon(Icons.ac_unit,color: Colors.white,size: 32,),)


//          IconBadge(Icons.pool),
//          IconBadge(Icons.message),
//          IconBadge(Icons.directions_run),
        ],
      ),
    );
  }
}


class IconBadge extends StatelessWidget{
  final IconData icon;
  final double size;
  IconBadge(this.icon,{
    this.size = 32.0
  });

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Icon(icon,size: size,color: Colors.grey,),
      width: size+60,
        height: size+60,
      color: Colors.white,
    );
  }
}